<template>
  <div>
    <BaseTable 
      :loading="loading"
      ref="trustOrderData"
      :data="tableData"
      :columns="columns" 
      @detailsdb="handlerClickdb"
      :tableHeight="tableHeight" 
      :pagination="false" ></BaseTable>
  </div>
</template>
<script>
import BaseTableCheck from '@/components/BaseTable/baseTablecheck'
import BaseTable from '@/components/BaseTable'
import publicapi from '@/api/public/index'
import api from '@/api/yardTally/carAppointment'
export default {
  components: { BaseTable,BaseTableCheck },
  props: {
    setformData: {
      type: Function
    },
    detailInfo: {
      type: Object
    }
  },
  data() {
    return{
      loading: false,
      tableData: [],
      columns: [
        {
          prop: 'planNo',
          label: '编号',
          width: 150
        },
        {
          prop: 'processName',
          label: '作业过程',
        },
        {
          prop: 'cargoCategoryName',
          label: '货种'
        },
        {
          prop: 'storehouseName',
          label: '作业场地',
        },
        {
          prop: 'tallyBack',
          label: '机械',
          width: 120
        },
        {
          prop: 'laborDispatch',
          label: '劳务',
        },
        {
          prop: 'nameVoyage',
          label: '船名航次',
          width: 120
        },
        {
          prop: 'remark',
          label: '备注',
        },
        {
          prop: 'approvalStatus',
          label: '状态',
          render(h,params) {
            if (params.row.approvalStatus == '1') {
              return h('el-tag', {
                props: {
                  size: 'mini'
                },
                domProps: {
                  innerHTML: '未审核'
                }
              })
            } else if (params.row.approvalStatus == '2') {
              return h('el-tag', {
                props: {
                  size: 'mini',
                  type: 'success'
                },
                domProps: {
                  innerHTML: '已审核'
                }
              })
            }
          }
        },
      ],
      tableHeight: window.innerHeight - 130,
      // 页码
      queryall: {
        totalNum: 0,
        startpage: 1,
        pagesize: 15
      },
      formLabelAlign: {
        time: '',
        workTime: '',
      },
      workTimeList: [],
      workDataList: [], //选中的作业指令
    }
  },
  created() {
    //  日期默认当天
		let date = new Date()
		let theYear = date.getFullYear() //获取完整的年份(4位)
		let theMonth = date.getMonth() + 1 //获取当前月份(1-12,1代表1月)
		theMonth = theMonth >= 10 ? theMonth : "0" + theMonth
		let theDay = date.getDate() //获取当前日(1-31)
		theDay = theDay >= 10 ? theDay : "0" + theDay
    this.formLabelAlign.time = theYear+'-'+theMonth+'-'+theDay
  },
  mounted() {
    this.getDictData()
    this.searchData()
  },
  methods: {
    // 查询字典信息
    getDictData () {
      publicapi.getDictData('SCHEDULE').then(res => {
        this.workTimeList = res.data.data.SCHEDULE
      })
    },
    // 查询列表信息
    searchData () {
      let params = {
        businessType: this.detailInfo.businessType
      }
      api.queryPlan(params).then(res => {
        this.tableData = res.data.data
      })
    },
    // 重置搜索信息
    resetFormForBusiness () {
      this.searchForm = {
        workDate: '',
      }
    },
    // 分页查询
    sizeChange(val) {
      this.queryall.pagesize = val;
      this.searchData();
    },
    // 分页查询
    pageChange(val) {
      this.queryall.startpage = val;
      this.searchData();
    },
    // 双击
    handlerClickdb (val) {
      this.setformData(val)
    },
  }
}
</script>
<style lang="less" scoped>
@import "../../../../assets/searchfrom.less";
</style>